<?php
include_once("../../../common/module/checkA.php");
include_once("../../../../config.php");
include_once("../controller/term-list.php");

$sys_belong = "product";
?>


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <? include_once(ROOT_PATH_ . "/controller/common/module/head.php"); ?>


</head>

<body>

<div id="topbar">
    <?php include ROOT_PATH_ . '/controller/common/module/topbar.php'; ?>
</div>

<div id="container">
    <!--Container端點01-->
    <div id="maincontent"   class="detail">
        <!--maincontent端點01-->

        <div id="sidebar">
            <?php include ROOT_PATH_ . '/controller/common/module/sidebar.php'; ?>
        </div>


        <div id="content">
            <fieldset class="layui-elem-field layui-field-title" style="margin-top: 30px;">
                <legend><h1>添加<? echo $sys_title ?> 分类</h1></legend>
            </fieldset>




            <div class="<? echo $system_part ?>">

                <div class="term-detail-boxes layui-form">
                    <ul class="detail-boxing">
                        <form id="formDemo" method="post" action="term-add-function.php?now_extender=<? echo $system_part?>" enctype="multipart/form-data" name="uploadfile" onsubmit="return checkRequired(ai_name);" class="  layui-form-pane" >
                            <input type="hidden" name="ai_belong" value="<? echo $sys_belong ?>"  />
                            <li class="name">
                                <label class="layui-form-label">分类名称：</label>
                                <div class="layui-input-block"><input type="text" class="layui-input"  name="ai_name" size="20" value=""></div>
                                <em class="explain">(<u style="color:red">*必填项目</u>,填写本分类的标题)</em>
                            </li>

                            <li class="term"><label class="layui-form-label">所属分类：</label>

                                <div class="layui-input-block">

                                    <select name="term_id">


                                        <option value="root" selected="selected">当前所属分类:根目录 \</option>
                                        <?
                                        $table_suffix = 'term';
                                        $table = $table_Prefix . $table_suffix;
                                        $sort_by = "nid";
                                        $sort_order = "desc";
                                        ?>

                                        <?php
                                        $query = mysql_query("SELECT COUNT(nid) FROM $table where interm = 'root' and belong ='$sys_belong'");
                                        $term0sum = mysql_result($query, 0);

                                        $result_term0 = mysql_query("select * from $table where interm='root' and belong = '$sys_belong' ORDER BY $sort_by $sort_order");

                                        while($row = mysql_fetch_array($result_term0))
                                        {
                                            $term0_nid[]=$row['nid'];
                                            $term0_name[]=$row['name'];
                                        }

                                        ?>
                                        <? for($i=0;$i<$term0sum;$i++) { ?>
                                            <option value="<?php echo $term0_nid[$i] ?>"> | - <?php echo $term0_name[$i] ?></option>
                                            <?
                                            $query2 = mysql_query("SELECT COUNT(nid) FROM $table where term1 = $term0_nid[$i] && interm = 'term1'  and belong ='$sys_belong'  ");
                                            $term1sum = mysql_result($query2, 0);
                                            if ($_REQUEST ['sortby']) {
                                                $sort_by = $_REQUEST ['sortby'];
                                            }
                                            $result1 = mysql_query("select * from $table where term1 = $term0_nid[$i] && interm = 'term1' and belong ='$sys_belong'  ORDER BY $sort_by ");
                                            while ($row = mysql_fetch_array($result1)) {
                                                {
                                                    $term1_nid[$i][] = $row['nid'];
                                                    $term1_mid[$i][] = $row['mid'];
                                                    $term1_name[$i][] = $row['name'];
                                                }
                                            }
                                            ?>
                                            <?for ($ii = 0; $ii < $term1sum; $ii++) {?>
                                                <option value="<?php echo $term1_nid[$i][$ii] ?>"> |---- <?php echo $term1_name[$i][$ii] ?></option>
                                            <?php } ?>
                                        <?php } ?>


                                    </select></div>
                                <em class="explain">(选择本分类对应的上级分类，如是一级分类，请选择“根目录”)</em></li>
                            <li  class="introduce"><label class="layui-form-label">分类简介：</label>
                                <div class="layui-input-block">
                                    <textarea name="ai_introduce" cols="20"></textarea></div>
                                <em class="explain">(填写本分类的分类概述文字)</em>
                            </li>

                            <li class="icon">
                                <label class="layui-form-label">ICON：</label>
                                <img src="../images/default-image.jpg" width="150"/>
                                <span class="title-data">(请上传像素<? echo $first_icon_data[0]?>X<? echo $first_icon_data[1]?>符合比例的图片,格式为jpeg)</span>
                            </li>
                            <li class="icon">
                                <label class="layui-form-label">上传文件：</label>
                                <div class="layui-input-block"><input type="file" name="ai_icon"  onchange="fileChange(this);"/></div>
                                <em class="explain">(上传本分类的列表图标)</em>
                            </li>
                            <br />


                            <li class="publish"><label class="layui-form-label">发布状态：</label>
                                <div class="layui-input-block">
                                    <input name='ai_publish' type='radio' value='1' id="publish_now" title="立即发布"/>

                                    <input name='ai_publish' type='radio' value='0' id="publish_later"  checked="checked" title="暂未发布"  />

                                </div>
                                <em class="explain">(选择立即发布，以上信息才能在前台显示；选择暂未发布，只对以上信息进行保存，不在前台显示)</em>
                            </li>


                            <li class="markorder"><label class="layui-form-label">标记排序：</label>
                                <div class="layui-input-block"><input type="text" class="layui-input"  name="ai_markorder" size="20" value="0" ></div>
                                <em class="explain">(填写分类在前台列表中的排序，数字越大，排序越靠前)</em>
                            </li>


                            <hr/>
                            <div class="function">
                                <input type="hidden" name="detail_attr" id="detail_attr" />
                                <button class="layui-btn "  type="submit" >立即提交</button>
                                <input type="reset" class="layui-btn" value="重置"/>
                            </div>
                        </form>
                    </ul>
                </div>
            </div>

            <!--content端點01-->
        </div>
        <!--maincontent端點01-->
        <br class="clearfloat" />
    </div>
    <!--container端點01-->
</div>

<!--container端點01-->
</div>








<?php include ROOT_PATH_ . "/controller/common/module/footer.php"; ?> </body>

</html>

